let MIXIN = {
	data() {
		return {
			title: '多米街',
			path: '',
		}
	},
	onLoad(options) {
		let mid = '';
		if (options.mid) {
			mid = options.mid;
		}
		if (options.scene) {
			let scene = decodeURIComponent(options.scene);
			mid = this.gup('mid', scene);
		}
		if(mid!=''){
			uni.setStorageSync('mid', mid);
		}
		
		let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
		if (routes.length > 0 && routes[routes.length - 1].$page) {
			this.path = routes[routes.length - 1].$page.fullPath; //获取当前页面路由
			console.log(this.path);
			if (this.path.indexOf('/product/list') != -1 || this.path.indexOf('/mallHome/index') != -1 ||this.path.indexOf('/product/product') != -1 || this.path
				.indexOf('/shoplist/shopgoods') != -1 || this.path.indexOf('/index/index') != -1 || this.path.indexOf('/product/groupbuy') != -1) {
				let type = this.path.indexOf('/product/list') != -1 ? 'goodsList' : this.path.indexOf(
						'/product/product') != -1 ? 'goods' : this.path.indexOf('/index/index') != -1 ? 'home' :
					'merch';
				if(this.path.indexOf('/product/groupbuy') != -1){
					type='goods';
				}
				if(this.path.indexOf('/mallHome/index') != -1){
					type='home';
				}
				let cid = routes[routes.length - 1].options.id ? routes[routes.length - 1].options.id : 0;
				let obj = {
					url: this.path,
					type,
					cid
				};
				this.$axios('WxInfo/getConfig', 'POST', 'shop', obj).then(res => {
					if (res.data.code == 200) {
						this.path = res.data.data.shareinfo.url;
					}
				})
			}
		}
	},
	methods: {
		gup(name, url) {
			if (url) url = url ? '?' + url : location.href;
			name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
			var regexS = "[\\?&]" + name + "=([^&#]*)";
			var regex = new RegExp(regexS);
			var results = regex.exec(url);
			return results == null ? null : results[1];
		}
	},
	//转发分享
	 onShareAppMessage() {
	 	return {
	 		title: this.title,
	 		path: this.path
	 	}
	 },
	 onShareTimeline() {
	 	return {
	 		title: this.title,
	 		path: this.path
	 	}
	 },
};
export default MIXIN;